package com.example.music.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @ClassName ConstantPropertiesUtils
 * @Author: wx
 * @Create: 2022-10-06  16:04
 * @Description TODO
 * @Version: 1.0
 **/
@Component
public class ConstantPropertiesUtils implements InitializingBean {
    /**
     * ip
     **/
    @Value("${FTP.ADDRESS}")
    private String host;
    /**
     * 端口
     **/
    @Value("${FTP.PORT}")
    private int port;
    /**
     * ftp用户名
     */
    @Value("${FTP.USERNAME}")
    private String userName;
    /**
     * ftp用户密码
     */
    @Value("${FTP.PASSWORD}")
    private String passWord;
    /**
     * 文件在服务器端保存的主目录
     */
    @Value("${FTP.BASEPATH}")
    private String basePath;
    /**
     * 访问图片时的基础url
     */
    @Value("${IMAGE.BASE.URL}")
    private String baseUrl;

    /**
     * 本地字符编码
     */
    @Value("${FTP.LOCALCHARSET}")
    private String localCharset;

    /**
     * FTP协议里面，规定文件名编码为iso-8859-1
     */
    @Value("${FTP.SERVERCHARSET}")
    private String serverCharset;

    public static String HOST;
    public static int PORT;
    public static String USERNAME;
    public static String PASSWORD;
    public static String BASE_PATH;
    public static String BASE_URL;
    public static String LOCAL_CHARSET;
    public static String SERVER_CHARSET;

    @Override
    public void afterPropertiesSet() throws Exception {
        HOST = host;
        PORT = port;
        USERNAME = userName;
        PASSWORD = passWord;
        BASE_PATH = basePath;
        BASE_URL = baseUrl;
        LOCAL_CHARSET = localCharset;
        SERVER_CHARSET = serverCharset;
    }
}
